package com.applet.applet_shangcheng.service;

import com.applet.applet_shangcheng.dao.ImagesMapper;
import com.applet.applet_shangcheng.entity.Images;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ImageService {
    @Autowired
    private ImagesMapper imagesMapper;

    public int insertImage(String fileName,String imageUrl){
        Images images = new Images();
        images.setFileName(fileName);
        images.setImageUrl(imageUrl);
        String str="0";
        images.setStatus(str);
        int i = imagesMapper.insertImage(images);
        return i;
    };

    public  List<Images> selectImage(){
        List<Images> imagesList = imagesMapper.selectImage();
        return imagesList;
    };

    public List<Images> findByUrl(String imageUrl){
        List<Images> imagesList = imagesMapper.findByUrl(imageUrl);
        return imagesList;
    };

    public int deleteImage(String imageUrl){
        int i = imagesMapper.deleteImage(imageUrl);
        return i;
    };

    public int updateImageStatus(String image){
        int i = imagesMapper.updateImageStatus(image);
        return i;
    };
}
